import request from './request'
// 得到首页推荐列表
export function getArticles (params) {
  console.log('yibu')
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    params
  })
}
// 得到所有频道列表
export function getAllChannelsList () {
  return request({
    method: 'GET',
    url: '/app/v1_0/channels'
  })
}
// 得到文章详情
export function getEssay (essayId) {
  return request({
    method: 'GET',
    url: `/app/v1_0/articles/${essayId}`
  })
}
// 点赞文章
export function likingEssay (essayId) {
  return request({
    method: 'post',
    url: '/app/v1_0/article/likings',
    data: {
      target: essayId
    }
  })
}
// 取消点赞文章
export function cancelLikingEssay (essayId) {
  return request({
    method: 'DELETE',
    url: `/app/v1_0/article/likings/${essayId}`
  })
}
// 收藏文章
export function followEssay (essayId) {
  return request({
    method: 'POST',
    url: '/app/v1_0/article/collections',
    data: {
      target: essayId
    }
  })
}
// 取消收藏文章
export function cancelFollowEssay (essayId) {
  return request({
    method: 'DELETE',
    url: `/app/v1_0/article/collections/${essayId}`
  })
}
// 获得文章评论
export function getEssayComment (params) {
  return request({
    method: 'GET',
    url: '/app/v1_0/comments',
    params
  })
}
// 对评论点赞
export function likingComment (commentId) {
  return request({
    method: 'POST',
    url: '/app/v1_0/comment/likings',
    data: {
      target: commentId
    }
  })
}
// 取消点赞
export function cancelLikingComment (commentId) {
  return request({
    method: 'delete',
    url: `/app/v1_0/comment/likings/${commentId}`
  })
}
// 添加评论或评论回复
export function addComment (data) {
  return request({
    method: 'POST',
    url: '/app/v1_0/comments',
    data
  })
}
